<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>

<script type="text/javascript">
	function chained(funcs){
		return function(input){
			return funcs.reduce(function(input,fn){
				console.log(input)
				return fn(input)
			},input)
		}
	}

	function f4(x){ return x.split("").concat().reverse().join("").split(" ")}
	function f5(xs){ return xs.concat().reverse() }
	function f6(xs){ return xs.join("_") }
	var a=chained([f4,f5,f6])("lorem ipsum")
	//f6(f5(f4('lorem ipsum')))
	console.log(a)
	chained=(...funcs)=>funcs.reduce(ret,item)=>(...args)=>item(ret(...args))
	chained=function(...funcs){
		return funcs.reduce(function(ret,item){
			return function(...args){
				return item(ret(...args))
			}
		})
	}
</script>
</body>
</html>
